package unicall.em.models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import unicall.em.base.BaseModel;
import unicall.em.dtos.SkillDto;
@Entity
@Table(name="CC_SKILL")
@NamedQueries(value = { @NamedQuery(name = "Skill.findAll", query = "select a from Skill a") })
public class Skill extends BaseModel {
    //队列名
    private String name;
    //队列编号
    private String queueId;
    //最大排队数
    private int maxNum;
    //排队等待音
    private String mediaId;
    //退出队列按键
    private String exitKey;
    //排队超时时长
    private int timeoutLen;
    //排队超时音
    private String timeoutMediaId;
    //继续排队按键
    private String continuteKey;
    //最大排队次数
    private String maxQueueCount;
    //接通后播放提示音
    private String tipMediaId;
    //分配策略
    private String strategy;
    //未接听超时置闲时长
    private int noAnswerTimeout;
    //挂机后超时置闲时长
    private int acwTimeout;
    //是否开启顺振
    private int sequenceRing;
    //状态
    private String state;
    
    public Skill(){
        this.setCreatedAt(new Date());
        this.setUpdatedAt(new Date());
        this.setState(State.READY.getState());
        this.setStatus(STATUS.USE.getValue());
    }

    public String getQueueId() {
        return queueId;
    }

    public void setQueueId(String queueId) {
        this.queueId = queueId;
    }

    public int getMaxNum() {
        return maxNum;
    }

    public void setMaxNum(int maxNum) {
        this.maxNum = maxNum;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    public String getExitKey() {
        return exitKey;
    }

    public void setExitKey(String exitKey) {
        this.exitKey = exitKey;
    }

    public int getTimeoutLen() {
        return timeoutLen;
    }

    public void setTimeoutLen(int timeoutLen) {
        this.timeoutLen = timeoutLen;
    }

    public String getTimeoutMediaId() {
        return timeoutMediaId;
    }

    public void setTimeoutMediaId(String timeoutMediaId) {
        this.timeoutMediaId = timeoutMediaId;
    }

    public String getContinuteKey() {
        return continuteKey;
    }

    public void setContinuteKey(String continuteKey) {
        this.continuteKey = continuteKey;
    }

    public String getMaxQueueCount() {
        return maxQueueCount;
    }

    public void setMaxQueueCount(String maxQueueCount) {
        this.maxQueueCount = maxQueueCount;
    }

    public String getTipMediaId() {
        return tipMediaId;
    }

    public void setTipMediaId(String tipMediaId) {
        this.tipMediaId = tipMediaId;
    }

    public String getStrategy() {
        return strategy;
    }

    public void setStrategy(String strategy) {
        this.strategy = strategy;
    }

    public int getNoAnswerTimeout() {
        return noAnswerTimeout;
    }

    public void setNoAnswerTimeout(int noAnswerTimeout) {
        this.noAnswerTimeout = noAnswerTimeout;
    }

    public int getAcwTimeout() {
        return acwTimeout;
    }

    public void setAcwTimeout(int acwTimeout) {
        this.acwTimeout = acwTimeout;
    }

    public int getSequenceRing() {
        return sequenceRing;
    }

    public void setSequenceRing(int sequenceRing) {
        this.sequenceRing = sequenceRing;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public SkillDto toDto(){
        SkillDto  dto = new SkillDto();
        dto.setId(this.getId());
        dto.setName(this.name);
        dto.setTenantId(this.getTenantId());
        dto.setQueueId(this.queueId);
        dto.setMaxNum(this.maxNum);
        dto.setMediaId(this.mediaId);
        dto.setExitKey(this.exitKey);
        dto.setTimeoutLen(this.timeoutLen);
        dto.setTimeoutMediaId(this.timeoutMediaId);
        dto.setContinuteKey(this.continuteKey);
        dto.setMaxQueueCount(Integer.parseInt(this.maxQueueCount));
        dto.setTipMediaId(this.tipMediaId);
        dto.setStrategy(this.strategy);
        dto.setNoAnswerTimeout(this.noAnswerTimeout);
        dto.setAcwTimeout(this.acwTimeout);
        dto.setSequenceRing(this.sequenceRing);
        dto.setState(this.state);
        dto.setCreatedAt(this.getCreatedAt());
        dto.setUpdatedAt(this.getUpdatedAt());
        return dto;
    }
    
    
    private enum State{
        READY("ready"),RSYNC("rsync"),ERROR("error");
        private  String name;
        private State(String name){
            this.name = name;
        }
       public String getState(){
           return this.name;
       }
    }
    
    
    
}
